<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="/css/news.css"/>
    <style>
        li {
            list-style: inherit !important;
        }
    </style>
</head>

<body class="childrenBody">
<form class="layui-form" action="">
    <!--<div class="layui-form-item">-->
        <!--<label class="layui-form-label">用户ID</label>-->
        <!--<div class="layui-input-block">-->
            <!--<input type="text" lay-verify="required" placeholder="请输入用户ID" class="layui-input"-->
                   <!--id="userid">-->
        <!--</div>-->
    <!--</div>-->
    <div class="layui-form-item">
        <label class="layui-form-label">买家会员名</label>
        <div class="layui-input-block">
            <input type="text" lay-verify="required" placeholder="请输入买家会员名" class="layui-input"
                   id="username">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">联系人姓名</label>
        <div class="layui-input-block">
            <input type="text" lay-verify="required" placeholder="请输入联系人姓名" class="layui-input"
                   id="linkname">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">联系手机</label>
        <div class="layui-input-block">
            <input type="text" lay-verify="required" placeholder="请输入联系手机" class="layui-input"
                   id="linkphone">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">收货地址</label>
        <div class="layui-input-block">
            <input type="text" lay-verify="required" placeholder="请输入收货地址" class="layui-input"
                   id="linkaddress">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">买家留言</label>
        <div class="layui-input-block">
            <input type="text" lay-verify="required" placeholder="请输入买家留言" class="layui-input"
                   id="usermemo">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">订单备注</label>
        <div class="layui-input-block">
            <input type="text" lay-verify="required" placeholder="请输入订单备注" class="layui-input"
                   id="ordermemo">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">宝贝数量</label>
        <div class="layui-input-block">
            <input type="text" lay-verify="required|number" placeholder="请输入宝贝数量" class="layui-input"
                   id="goodnum">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">修改后的收货地址</label>
        <div class="layui-input-block">
            <input type="text" lay-verify="required" placeholder="请输入修改后的收货地址" class="layui-input"
                   id="newaddress">
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">支付方式</label>
            <div class="layui-input-inline">
                <select name="modules" lay-verify="required" id="paytype" lay-filter="paytype">
                    <option value="0">未支付</option>
                    <option value="1">微信</option>
                    <option value="2">余额</option>
                    <option value="3">线下支付</option>
                </select>
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">订单类型</label>
            <div class="layui-input-inline">
                <select name="modules" lay-verify="required" id="ordertype" lay-filter="ordertype">
                    <option value="1">安装</option>
                    <option value="2">维修</option>

                </select>
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">创建时间</label>
        <div class="layui-input-block">
            <input type="text" lay-verify="required" placeholder="" class="layui-input"
                   id="createtime">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">后台分配时间</label>
        <div class="layui-input-block">
            <input type="text" lay-verify="required" placeholder="" class="layui-input"
                   id="fpTime">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">工人确认时间</label>
        <div class="layui-input-block">
            <input type="text" lay-verify="required" placeholder="" class="layui-input"
                   id="confirmTime">
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">订单状态</label>
            <div class="layui-input-inline">
                <select name="modules" lay-verify="required" id="status" lay-filter="status">
                    <option value="-1">已关闭</option>
                    <option value="0">待分配</option>

                    <option value="1">待确认</option>
                    <option value="2">待完成</option>
                    <option value="3">已分配</option>
                </select>
            </div>
        </div>
    </div>
    <!--<a class="layui-btn layui-btn-mini layui-btn-normal news_edit" onclick=test()><i-->
            <!--class="layui-icon">&#xe642;</i>打印</a>-->
    <div class="layui-form-item">
        <div class="layui-input-block">
            <a style="display:none;" class="layui-btn layui-btn-normal" lay-submit="" lay-filter="edit"
               id="edit">立即修改</a>
            <a style="display:none;" class="layui-btn layui-btn-normal" lay-submit="" lay-filter="add" id="add">立即提交</a>
            <a class="layui-btn layui-btn-primary close">关闭</a>
        </div>
    </div>
</form>
<script type="text/javascript" src="../../js/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="../../layui/layui.js"></script>
<script type="text/javascript" src="../../js/wangEditor.js"></script>
<script type="text/javascript" src="../../js/basic.js"></script>
<script>

    layui.use('laydate',function(){
        var laydate = layui.laydate;
        laydate.render({
            elem:'#fpTime'
            ,type:'datetime'
        });
        laydate.render({
            elem:'#confirmTime'
            ,type:'datetime'
        });
        laydate.render({
            elem:'#createtime'
            ,type:'datetime'
        });
    });
    function edit() {
        var id = GetQueryString("id");
        var topM = layer.msg('数据提交中，请稍候', {icon: 16, time: false, shade: 0.8});
        $.ajax({
            type: "post",
            url: "/courierorder/update",
            data: {
                userid: $("#userid").val(),
                username: $("#username").val(),
                linkname: $("#linkname").val(),
                linkphone: $("#linkphone").val(),
                linkaddress: $("#linkaddress").val(),
                usermemo: $("#usermemo").val(),
                ordermemo: $("#ordermemo").val(),
                goodnum: $("#goodnum").val(),
                newaddress: $("#newaddress").val(),
                paytype: $("#paytype").val(),
                ordertype: $("#ordertype").val(),
                fpTime: $("#fpTime").val(),
                confirmTime: $("#confirmTime").val(),
                status: $("#status").val(),
                courierorderId: id
            },
            dataType: "json",
            success:

                function (data) {
                    backData(data, topM);
                }
        })
        ;
    }

    function add() {
        var topM = layer.msg('数据提交中，请稍候', {icon: 16, time: false, shade: 0.8});
        $.ajax({
            type: "post",
            url: "/courierorder/save",
            data: {
                userid: $("#userid").val(),
                username: $("#username").val(),
                linkname: $("#linkname").val(),
                linkphone: $("#linkphone").val(),
                linkaddress: $("#linkaddress").val(),
                usermemo: $("#usermemo").val(),
                ordermemo: $("#ordermemo").val(),
                goodnum: $("#goodnum").val(),
                newaddress: $("#newaddress").val(),
                paytype: $("#paytype").val(),
                ordertype: $("#ordertype").val(),
                fpTime: $("#fpTime").val(),
                confirmTime: $("#confirmTime").val(),
                status: $("#status").val(),
                extra:
                    1
            },
            dataType: "json",
            success:

                function (data) {
                    backData(data, topM);
                }
        })

    };

    function backData(data, topM) {
        if (data.status == 0) {

            setTimeout(function () {
                layer.close(topM);
                top.layer.msg("修改成功！");
                //刷新父页面
                parent.getList({});
                var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                parent.layer.close(index); //再执行关闭
            }, 500);
        } else {
            layer.close(topM);
            layer.msg(data.msg, {icon: 1});
        }
    }

    function begin() {
        var op = GetQueryString("op");
        if (op == "add") {
            $("#add").show();
            return;
        }
        if (op == "edit") {
            $("#edit").show();
        }
        var id = GetQueryString("id");
        $.ajax({
            type: "post",
            url: "/courierorder/info",
            data: {
                courierorderId: id
            },
            dataType: "json",
            success: function (data) {
                console.log((data));
                if (data.status == 0) {

                    $("#id").val(data.result.id);


                    $("#userid").val(data.result.userid);


                    $("#username").val(data.result.username);


                    $("#linkname").val(data.result.linkname);


                    $("#linkphone").val(data.result.linkphone);


                    $("#linkaddress").val(data.result.linkaddress);


                    $("#usermemo").val(data.result.usermemo);


                    $("#ordermemo").val(data.result.ordermemo);


                    $("#goodnum").val(data.result.goodnum);


                    $("#newaddress").val(data.result.newaddress);


                    $("#paytype").val(data.result.paytype);


                    $("#ordertype").val(data.result.ordertype);


                    $("#createtime").val(getTime(data.result.createtime));


                    $("#fpTime").val(getTime(data.result.fpTime));


                    $("#confirmTime").val(getTime(data.result.confirmTime));


                    $("#status").val(''+ data.result.status);
                    layui.form.render();

                } else {
                    layer.msg(data.msg, {icon: 1});
                }
            }
        });
    }
function test(){
        var flag = $('#status').val();
        alert((flag));
}
    //点击取消关闭当前弹窗
    $(".close").click(function () {
//当你在iframe页面关闭自身时
        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
        parent.layer.close(index); //再执行关闭
    })

    layui.use(['form'], function () {
        var form = layui.form;
        //监听提交
        form.on('submit(add)', function (data) {
            add()
            return false;
        });

        //监听提交
        form.on('submit(edit)', function (data) {
            edit()
            return false;
        });
        begin();
    });

</script>
</body>
</html>